const Sequelize = require('sequelize');
const baseModel = require('../baseModel');

class chapterModel extends baseModel{
  constructor(){
    super('chapter',{
      id:{
        type: Sequelize.INTEGER,
        autoIncrement: true,
        allowNull: false,
        primaryKey:true
      },
      // 章节代号 用于排序
      order:{
        type: Sequelize.INTEGER,
        allowNull: false
      },
      // 机构id
      org: {
        type: Sequelize.INTEGER,
        allowNull: false
      },
      // 系列id
      series: {
        type: Sequelize.INTEGER,
        allowNull: false
      },
      name:{
        type: Sequelize.STRING(15),
        allowNull: false
      },
      page_url:{
        type: Sequelize.STRING,
        allowNull: false
      },
      map_url:{
        type: Sequelize.STRING,
        allowNull: false
      },
      points:{
        type: Sequelize.STRING,
        allowNull: false
      },
      updatedAt:{
        type: Sequelize.DATE,
        allowNull: false
      },
      createdAt:{
        type: Sequelize.DATE,
        allowNull: false
      }
    });
    this.model = super.getModel();
    this.model.sync();
  }
}

module.exports = new chapterModel();
